/**
 * 
 */
package co.edu.javeriana.ia.ga;

import org.jgap.Configuration;
import org.jgap.DefaultFitnessEvaluator;
import org.jgap.InvalidConfigurationException;
import org.jgap.event.EventManager;
import org.jgap.impl.BestChromosomesSelector;
import org.jgap.impl.ChromosomePool;
import org.jgap.impl.CrossoverOperator;
import org.jgap.impl.GABreeder;
import org.jgap.impl.MutationOperator;
import org.jgap.impl.StockRandomGenerator;
import org.jgap.util.ICloneable;

/**
 * <p>
 * Clase Configuracion
 * </p>
 * 
 * @author <a href=f.triana@javeriana.edu.co">Alejandro Triana</a>
 * @version 1.0
 */
public class GenConfiguration extends Configuration implements ICloneable {
	
	private static final long serialVersionUID = 1L;

	public GenConfiguration() {
		this("", "");
	}

	/**
	 *<p>
	    *Configuracion por defecto
	 *</p>
	 */
	public GenConfiguration(String a_id, String a_name) {
		super(a_id, a_name);
		try {
			setBreeder(new GABreeder());
			setRandomGenerator(new StockRandomGenerator());
			setEventManager(new EventManager());
			BestChromosomesSelector bestChromsSelector = new BestChromosomesSelector(
					this, 0.90d);
			bestChromsSelector.setDoubletteChromosomesAllowed(true);
			addNaturalSelector(bestChromsSelector, false);
			setMinimumPopSizePercent(0);
			//
			setSelectFromPrevGen(1.0d);
			setKeepPopulationSizeConstant(true);
			setFitnessEvaluator(new DefaultFitnessEvaluator());
			setChromosomePool(new ChromosomePool());
			addGeneticOperator(new CrossoverOperator(this, 0.35d));
			addGeneticOperator(new MutationOperator(this, 12));
			setUniqueKeysActive(true);
			setPreservFittestIndividual(true);
			
		} catch (InvalidConfigurationException e) {
			throw new RuntimeException(
					"Error cargando la configuracion");
		}
	}

	/**
	 * @return deep clone of this instance
	 */
	public Object clone() {
		return super.clone();
	}

}
